/**
 * Copyright (c) 2007,中企动力华南研发中心<br>
 * All rights reserved.<br>
 */
package com.ce.pms.system.renovation.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.base.vo.SearchVO;
import com.ce.pms.system.renovation.dao.IRenovateChargeItemConfigDao;
import com.ce.pms.system.renovation.model.RenovateChargeItemConfigDO;
import com.sitechasia.webx.core.support.Page;

/**
 * 功能描述：<br>
 * @author 易贤建 创建日期：2008-12-30<br>
 */
public class RenovateChargeItemConfigDaoImpl extends PmsBaseDaoImpl implements
		IRenovateChargeItemConfigDao {
	/**
	 * 功能描述:通过ID查询DO<br>
	 * @param keyword
	 * @return
	 * Create author:yixianjian <br>
	 * Create on:2008-12-30  <br>
	 */
	public RenovateChargeItemConfigDO findRenovateChargeItemConfigById(Long keyword){
		StringBuffer queryStr = new  StringBuffer( "FROM RenovateChargeItemConfigDO chargeItemConfig ");
		queryStr.append(" WHERE chargeItemConfig.keyword=? ");
		Query query = super.createQuery(queryStr.toString(), keyword);
		return (RenovateChargeItemConfigDO)query.uniqueResult();
	}
	/**
	 * 功能描述:得到所有未停用的装修收费项目<br>
	 * @return<br>
	 * Create author:罗军林<br>
	 * Create on:2008-12-24<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	@SuppressWarnings("unchecked")
	public List<RenovateChargeItemConfigDO> getAllRenovateChargeItemConfigs(){
		StringBuffer queryStr = new  StringBuffer( "FROM RenovateChargeItemConfigDO chargeItemConfig ");
		queryStr.append("WHERE chargeItemConfig.state='001' ");
		queryStr.append(" ORDER BY chargeItemConfig.sysInfo.sysDate DESC");
		return super.findAllResult(queryStr.toString(), null);
	}
	/**
	 * 功能描述:装修收费登记项目查询<br>
	 * @param searchVO
	 * @return
	 * Create author:yixianjian <br>
	 * Create on:2008-12-30  <br>
	 */
	public Page queryRenovateChargeItemList(SearchVO searchVO){
		StringBuffer queryStr = new  StringBuffer( "FROM RenovateChargeItemConfigDO chargeItemConfig ");
									queryStr.append("WHERE 1=1 ");
									queryStr.append(" ORDER BY chargeItemConfig.sysInfo.sysDate DESC");
		return super.pagedQueryByPageNo(queryStr.toString(), searchVO.getPageNo(), searchVO.getPageSize());
	}
	/**
	 * 功能描述:查询所有名称一样的装修收费项目<br>
	 * @param itemName
	 * @return
	 * Create author:yixianjian <br>
	 * Create on:2009-1-4  <br>
	 */
	@SuppressWarnings("unchecked")
	public List<RenovateChargeItemConfigDO> findByItemName(String itemName){
		StringBuffer queryStr = new  StringBuffer( "FROM RenovateChargeItemConfigDO chargeItemConfig ");
								queryStr.append(" WHERE 1=1 ");
								queryStr.append(" AND chargeItemConfig.itemName=? ");
	    Query query = super.createQuery(queryStr.toString(), itemName);
	    return query.list();
	}
	/**
	 * 功能描述:查询项目名称一样,keyword不一样的装修收费项目<br>
	 * @param keyword
	 * @param itemName
	 * @return
	 * Create author:yixianjian <br>
	 * Create on:2009-1-4  <br>
	 */
	@SuppressWarnings("unchecked")
	public List<RenovateChargeItemConfigDO> findByItemNameWithoutKeyword(Long keyword,String itemName){
		StringBuffer queryStr = new  StringBuffer( "FROM RenovateChargeItemConfigDO chargeItemConfig ");
							queryStr.append(" WHERE 1=1 ");
							queryStr.append(" AND chargeItemConfig.keyword!=?");
							queryStr.append(" AND chargeItemConfig.itemName=? ");
		Query query = super.createQuery(queryStr.toString(), keyword,itemName);
		return query.list();
	}
}
